package com.yn.common.response.zy;


import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yn.common.constants.Constants;
import com.yn.common.enums.OrganTypeEnum;
import com.yn.common.model.zy.TOrganInfoDO;
import com.yn.common.utils.BeanUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

@Data
@ApiModel("机构分页信息出参")
public class OrganQueryResponse {

    @ApiModelProperty("主键id")
    private Integer id;

    @ApiModelProperty("结构名称")
    private String organName;

    @ApiModelProperty("机构图片")
    private String organImageUrl;

    @ApiModelProperty("机构类型(1:医院 2:康复3:养老机构)")
    private String organType;

    @ApiModelProperty("机构类型字符串")
    private String organTypeStr;

    @ApiModelProperty("收费")
    private Integer price;

    @ApiModelProperty("收费单位(年/月)")
    private String unit;

    @ApiModelProperty("单位字典值")
    private String unitStr;

    @ApiModelProperty("区域编码")
    private String regionCode;

    @ApiModelProperty("详细地址")
    private String regionDetailInfo;


    @JsonFormat(pattern = Constants.DATE_FORMAT)
    @ApiModelProperty("创建时间")
    private Date createTime;

    @JsonFormat(pattern = Constants.DATE_FORMAT)
    @ApiModelProperty("修改时间")
    private Date updateTime;
    public static OrganQueryResponse transform(TOrganInfoDO tOrganInfoDO){
        if (ObjectUtils.isEmpty(tOrganInfoDO)) {
            return null;
        }
        OrganQueryResponse response = new OrganQueryResponse();
        BeanUtil.copyProperties(tOrganInfoDO,response );
        //机构类型字符串
        response.setOrganTypeStr(OrganTypeEnum.getByCode(tOrganInfoDO.getOrganType()).getName());
        return response;
    }
}
